import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { BlogArticle } from '../entities/blog_article.entity';
@Injectable()
export class BlogArticleService {
  constructor(
    @InjectRepository(BlogArticle)
    private readonly articleRepository: Repository<BlogArticle>,
  ) {}

  async getBlogArticle(id?: number): Promise<BlogArticle> {
    const res = await this.articleRepository.findOneById(id);
    return res;
  }
  async getBlogArticles(): Promise<BlogArticle[]> {
    return await this.articleRepository.find();
  }
}
